package cmpe273.proj1.dao;

import cmpe273.proj1.model.Instructor;
import cmpe273.proj1.model.Student;

/**
 * This interface represents a contract for a DAO for the {@link User} model.
 *
 * @author BalusC
 * @link http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html
 */
public interface UserDAO {

    // Actions ------------------------------------------------------------------------------------

    /**
     * Create the given User in the database. The Student ID must NOT be null, otherwise it will throw
     * IllegalArgumentException.
     * @param s The Student to create a user for.
     * @throws IllegalArgumentException If the Student ID is null.
     * @throws DAOException If something fails at database level.
     */
    public void create(Student s, String password) throws IllegalArgumentException, DAOException;
    
    /**
     * Create the given User in the database. The Instructor ID must NOT be null, otherwise it will throw
     * IllegalArgumentException.
     * @param i The Instructor to create a user for.
     * @throws IllegalArgumentException If the Student ID is null.
     * @throws DAOException If something fails at database level.
     */
    public void create(Instructor i, String password) throws IllegalArgumentException, DAOException;
    
    /**
     * Update the given session password
     * IllegalArgumentException.
     * @param username The user to update in DB.
     * @param password The new password.
     * @throws DAOException If something fails at database level.
     */
    public void updatePassword(String username, String password) throws DAOException;
    
    /**
     * Login the given person to the database. The DB will generate and return a session ID
     * @param username The User to login.
     * @param password The Password to attempt.
     * @throws DAOException If something fails at database level.
     */
    public String login(String username, String password) throws DAOException;
    
    /* "" == no student permissions, "S<studentId>" == student permission, "I<instructorId>" == instructor permission, "Admin == admin permission" */
    public String verifyPermissions(String sessionId) throws DAOException;
    
    public void logout(String sessionId) throws DAOException;
}